package vpfarm.master;

import java.util.ArrayList;

import jtools.ai.agenten.AMessage;
import jtools.ai.agenten.CycleBehavior;
import vpfarm.Constants;
import vpfarm.data.RenderResult;

public class ReciveRenderResultBehavior extends CycleBehavior {

	private Master master;

	public ReciveRenderResultBehavior(Master master) {
		this.master = master;
	}

	public void execute() {
		AMessage msg = myAgent.reciveMessage(true);
		if (msg.getSubject() == Constants.SEND_RENDER_RESULT){
			ArrayList<RenderResult> rr =  (ArrayList<RenderResult>) msg.getContent();
			for (int i =  0; i < rr.size(); i++)
				this.master.finishFrames(rr.get(i));
		}else
			myAgent.pushBack(msg);
	}

	public void onEnd() {
	}

	public void onStart() {
	}

}
